<div class="walk-home-container">
	<div class="sponsor-login-existing">
		<h2>Existing User:</h2>
		<div class="validation-errors" id="validationErrors" style="display:none; width: 300px;"></div>
		<?php
			Includes::IncludeFile( Includes::$FORM );
		
			echo( form_open(base_url() . 'cmb/sponsor_walker/login_process/' . $urlKey . '/' , array('id' => 'loginForm') ) );
				
				if( $loginFailed )
				{
					echo('<div><strong>Invalid User Name and/or Password</strong></div>');
				}
				
				Form::OpenFormItem('User Name:', 260);
					echo( form_input(array('name'=>'userName','id'=>'userName','style'=>'width: 250px;', 'onkeyup'=>'loginKeyUp(event);')) );
				Form::CloseFormItem();
				Form::OpenFormItem('Password:', 260);
					echo( form_password(array('name'=>'password','id'=>'password','style'=>'width: 250px;', 'onkeyup'=>'loginKeyUp(event);')) );
				Form::CloseFormItem();
			echo( form_close() );
		?>
		<div>
			<a href="javascript: validate();"><img src="<?php echo( base_url() );?>assets/images/buttons/sign_in.gif" border="0"/></a>
		</div>
	</div>
	<div class="sponsor-login-register">
		<h2>New User:</h2>
		<a href="<?php echo( base_url() ); ?>/cmb/sponsor_walker/create_account/<?php echo( $urlKey ); ?>/"><img src="<?php echo( base_url() );?>assets/images/buttons/create_account.gif" border="0"/></a>
	</div>
	<div class="clear"></div>
</div>


<script type="text/javascript">
	function loginKeyUp(event)
	{
		if( event.keyCode == 13 )
		{
			validate();
		}
	}
	
	function validate()
	{
		new Ajax.Request(baseUrl + 'validation/login_validation/validate_login/', 
		{
			method:'post',
			parameters: Form.serialize( $('loginForm') ),
		  	onSuccess: function(response)
			{
				var result = response.responseText;
				
				if( result == 'VALIDATION_SUCCESS' )
				{
					$('loginForm').submit();
				}
				else
				{
					$('validationErrors').innerHTML = result;
					$('validationErrors').show();
					Effect.ScrollTo('validationErrors', { duration:'0.2', offset:-20 });
				}
			},
			onFailure: function(response){}
		});
	}
</script>